<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>用户签到情况</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
  <ul class="layui-tab-title">
    <li class="layui-this" type="button" onclick="getNoSign()">未签到
    </li>

      <li type="button"  onclick="getSign()">已签到
    </li>
  </ul>
  <div class="layui-card">
    <div class="layui-card-body">
      <table id="demo" class="layui-hide" lay-filter="test"></table>
    </div>
  </div>
</div>
<script type="text/html" id="imgTpl">
  <input type="hidden" id="img" value={{ d.img }} >
  <img style="display: inline-block; width: 100%; height: 100%;" src= {{ d.img }}>
</script>
<script type="text/html" id="Tpl">
  {{#  if(d.user_meetings[0].isSign == 0){ }}
  <a class="layui-btn layui-btn-normal layui-btn-xs">未签到</a>
  {{#  } else if(d.user_meetings[0].isSign == 1){ }}
  <a class="layui-btn layui-btn-danger layui-btn-xs">已签到</a>
  {{#  } }}
</script>
<script src="/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="/danmu/static/js/jquery-1.9.1.min.js"></script>
<script>
    var sign=[[${sign}]]
    var id = [[${meetingId}]]
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use([ 'laydate','layer', 'table'], function () {
        var $ = layui.$,
            form = layui.form,
            laydate = layui.laydate,
            table = layui.table,
            layer = layui.layer;
        // 日期定义
        laydate.render({
            elem : '#start',
            type : 'datetime',
            format: 'yyyy-MM-dd HH:mm',
            done : function(value) {
                laydate.render({
                    elem : '#end',
                    type : 'datetime',
                    format: 'yyyy-MM-dd HH:mm',
                    min : value
                });
            }
        });

        table.render({
            elem: '#demo',
            url: '/user/sign1?sign='+sign+'&meetingId='+id+'',
            cellMinWidth : 95,   //全局定义所有常规单元格的最小宽度
            page : true,  //开启分页
            height : "full-125",  //设定容器高度
            id : "idTest",   //设定容器唯一 id。###此处特别重要，一定不可以重复!!!
            cols : [ [ //表头
                {
                    field : 'nickname',
                    title : '名字',
                    width : 100,
                },{
                    field : 'isSign',
                    title : '签到情况',
                    width : 100,
                    templet: '#Tpl'
                } ] ]
        });
    });
    function getNoSign() {
        console.log("onSing");
        $.ajax({
            type:"get",
            contentType : 'application/json',
            url:'/user/sign1?sign=0&meetingId='+id+'&page=1&limit=10',
            data:{},
            dataType : 'json',
            success:function(data) {
                layui.table.reload('idTest', {
                    url : '/user/sign1?sign=0&meetingId='+id+'&page=1&limit=10',
                    page : {
                        curr : 1
                    }
                });
            }
        });
    }
    function getSign() {
        $.ajax({
            type:"get",
            contentType : 'application/json',
            url:'/user/sign1?sign=1&meetingId='+id+'&page=1&limit=10',
            data:{},
            dataType : 'json',
            success:function(data) {
                layui.table.reload('idTest', {
                    url : '/user/sign1?sign=1&meetingId='+id+'&page=1&limit=10',
                    page : {
                        curr : 1
                    }
                });
            }
        });
    }
</script>
</body>
</html>
